package com.zHan.validation;

import com.zHan.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * ClassName: StateValidation
 * Description:
 * date: 2023/11/9 0009 20:04
 *
 * @author zHan
 */
public class StateValidation implements ConstraintValidator<State, String> {

    /**
     * @param value                      校验的字符串
     * @param constraintValidatorContext
     * @return
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        // 为空
        if (value == null) {
            return false;
        }
        if (value.equals("已发布") || value.equals("草稿")) {
            return true;
        }
        return false;
    }
}
